package mysql

import "gorm.io/gorm"

type Fitness struct {
	gorm.Model
	ClassName string  `gorm:"type:varchar(100);"`
	AddTime   string  `gorm:"type:date;"`
	Address   string  `gorm:"type:varchar(255);"`
	Teacher   string  `gorm:"char(10);"`
	Status    int64   `gorm:"type:int;default:0"`
	Num       int64   `gorm:"type:int;"`
	Price     float64 `gorm:"type:decimal(10,2);"`
}

func (f *Fitness) FindFitness(className string) (*Fitness, error) {
	err := DB.Where("class_name=?", className).Find(&f).Error
	if err != nil {
		return nil, err
	}
	return f, nil
}
func (f *Fitness) FindFitnessById(id int64) (fit []*Fitness, err error) {
	err = DB.Where("id=?", id).Find(&fit).Error
	if err != nil {
		return nil, err
	}
	return fit, nil
}
